<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH.'extensions/phpmailer/class.phpmailer.php');
function send_mail_template($to_mail,$template,$subject,$data=array()){
	$ci =& get_instance();
	$ci->load->helper('url');
	$mail = new PHPMailer();
	$mail->IsSMTP(); 
	//$mail->SMTPDebug  = 2;                                    
	$mail->SMTPAuth   = true;                  
	$mail->SMTPSecure = "ssl";
	$mail->Host       = "smtp.gmail.com";     
	$mail->Port       = 465;                    
	$mail->Username   = "marblenguyenmai@gmail.com"; 
	$mail->Password   = "phuongmai";            
	$mail->SetFrom('no-reply@raovathn.net',"Raovathn.net");
	$mail->AddReplyTo("no-reply@raovathn.net","Raovathn.net");
	$mail->AddAddress($to_mail);
	$mail->Subject    = $subject;
	$mail->CharSet = "utf-8";
	$body = $ci->load->view('_emails/'.$template,$data,TRUE);
	$mail->MsgHTML($body);
	if(!$mail->Send()) {
	  return $mail->ErrorInfo;
	}
	return true;
}

?>